<?php /* SVN: $Id: index_list.ctp 99 2008-07-09 09:33:42Z rajesh_04ag02 $ */ ?>
<div class="js-responses js-response">
	<?php
		if (!empty($this->request->params['named']['project_id'])) {
			$this->Html->meta('rss', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug, 'ext' => 'rss') , array('title' => 'RSS - ' . $this->pageTitle) , false);
		} else {
			$this->Html->meta('rss', array('controller' => 'blogs', 'action' => 'index', 'ext' => 'rss') , array('title' => 'RSS - ' . $this->pageTitle) , false);
		}
	?>
	<div class="blogs index">
	<div class="l-curve-top">
		<div class="r-curve-top">
			<div class="top-bg"></div>
		</div>
						</div>
						<div class="shad-bg-lft clearfix">
							<div class="shad-bg-rgt">
								<div class="shad-bg">
		<div class="main-section view-comments js-corner round-5">
                    <div class="comments-block">
            <div class="comments-top">
                    <div class="comment comment-arrow clearfix">
			<div class="grid_left">
            <h2>
				<?php
					if (!empty($this->request->params['named']['username'])):
						echo ucfirst($this->request->params['named']['username']) .__l('\'s updates');
					else :
						echo __l('Updates');
					endif;
					?>
						</h2>
						</div>
					 <div class="clearfix update-type grid_right">
					<?php
					if(!empty($this->request->params['named']['project_id'])):
				if ($project_owner == $this->Auth->user('id') || $this->Auth->user('user_type_id') == ConstUserTypes::Admin) :
						echo $this->Html->link(__l('Add Update'), array('controller' => 'blogs', 'action' => 'add', 'project_id' => $project_id), array('class' => 'add', 'title' => __l('Add Update')));
					endif;
					if (isset($this->request->params['named']['username'])) :
						if (isset($this->request->params['named']['tag'])) :
                            echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug,'username' => $this->request->params['named']['username'], 'tag' => $this->request->params['named']['tag'], 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' => sprintf(__l('Subscribe to %s'), $this->pageTitle)));
						elseif (isset($this->request->params['named']['category'])) :
							echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug, 'username' => $this->request->params['named']['username'], 'category' => $this->request->params['named']['category'], 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' => sprintf(__l('Subscribe to %s'), $this->pageTitle)));
						else :
							echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug, 'username' => $this->request->params['named']['username'], 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' => sprintf(__l('Subscribe to %s'), $this->pageTitle)));
						endif;
					elseif (isset($this->request->params['named']['tag'])) :
						echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug, 'tag' => $this->request->params['named']['tag'], 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' => sprintf(__l('Subscribe to %s'),  $this->pageTitle)));
					elseif (isset($this->request->params['named']['category'])) :
						echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index','project'=>$project_slug, 'category' => $this->request->params['named']['category'], 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' => sprintf(__l('Subscribe to %s'), $this->pageTitle)));
					else :
						echo $this->Html->link('RSS', array('controller' => 'blogs', 'action' => 'index', 'project'=>$project_slug, 'ext' => 'rss') , array('class' => 'rss-link grid_left','target' => 'blank', 'title' =>sprintf(__l('Subscribe to %s'), $this->pageTitle)));
					endif;
				endif;
				?>
				</div>
		
            </div>
            </div>
            </div>
           
				<?php
                
			?>
		
			<div class="clearfix">
			<?php
				if (empty($this->request->params['isAjax'])) :
					echo $this->Form->create('Blog', array('class' => 'normal grid_left clearfix', 'action'=>'index', 'type' => 'get'));?>
					<div class="grid_left"><?php echo $this->Form->input('q', array('label' => __l('Keywords'),'id'=>'Blogkeyword'));?></div>
					<?php echo $this->Form->input('project_id', array('type'=>'hidden')); ?>
					<div class="grid_left"><?php echo $this->Form->submit(__l('Search'));?></div>
				<?php	echo $this->Form->end();
				endif;
				
			?>
               <div class="grid_left">
				<?php echo $this->element('paging_counter'); ?>
				</div>
				</div>
   

		<ol class="list update-list">
			<?php
				if (!empty($blogs)):
					$i = 0;
					foreach($blogs as $blog):
						$class = null;
						if ($i++ % 2 == 0) {
							$class = 'altrow';
						}
			?>
			<li class="round-5 list-row clearfix" id="blog-<?php echo $blog['Blog']['id'];?>">
			<div class="clearfix">
				<div class="avatar1 grid_left alpha"><?php echo $this->Html->getUserAvatar($blog['Project']['User']['id'],'comment_avatar_thumb');?></div>
				<div class="data update-comments grid_11">
    		  
					<div class="clearfix listing-head">
						<h3 class="grid_7"><?php echo $this->Html->link($this->Html->cText($blog['Blog']['title'], false) , array('controller' => 'blogs', 'action' => 'view', $blog['Blog']['slug'])); ?></h3>
						<p class="date-block-info">
								<em title="<?php echo __l('On');?>"><?php echo __l('On');?></em>&nbsp;
								<span><?php echo $this->Html->cDateTimeHighlight($blog['Blog']['created']);?></span>
                                &nbsp;<em title="<?php echo __l('by');?>"><?php echo __l('by');?></em>&nbsp;
                                <span class="meta-row author">
			    		          <span title="<?php echo $blog['Project']['User']['username'];?>"><?php echo $this->Html->link($this->Html->cText($blog['Project']['User']['username']), array('controller'=> 'users', 'action' => 'view', $blog['Project']['User']['username']), array('escape' => false));?></span>
	    			            </span>
						</p>
                        	<dl class="feature-list update-list grid_left clearfix">
     							<?php if(Configure::read('Project.is_project_update_comment_enabled')): ?>
								<dt class="comments" title="<?php echo __l('Comments');?>"><?php echo __l('Comments');?></dt>
								<dd><?php echo $this->Html->cInt($blog['Blog']['blog_comment_count']);?></dd>
								<?php endif; ?>
								<dt class="views" title="<?php echo __l('Views');?>"><?php echo __l('Views');?></dt>
								<dd><?php echo $this->Html->cInt($blog['Blog']['blog_view_count']);?></dd>
							</dl>
					</div>
					 <div class="meta clearfix">
		    		
    			</div>
					<blockquote>
						<div class="js-truncate"><?php echo $this->Html->cHtml($this->Html->truncate($blog['Blog']['content'], 800)); ?></div>
					</blockquote>
					
					<?php if ($blog['Project']['user_id'] == $this->Auth->user('id') || $this->Auth->user('user_type_id') == ConstUserTypes::Admin): ?>
						<div class="user-opt view-update-links clearfix">
							<?php echo $this->Html->link(__l('Edit') , array('action' => 'edit', $blog['Blog']['id']) , array('class' => 'edit js-edit grid_left', 'title' => __l('Edit'))); ?>
							<?php echo $this->Html->link(__l('Delete') , array('action' => 'delete', $blog['Blog']['id']) , array('class' => 'delete js-delete grid_left', 'title' => __l('Delete'))); ?>
						</div>
					<?php endif; ?>
					<div class="clearfix">
                        <h3 class="tag"><?php echo __l('Tags');?></h3>
                        <ul class="tags clearfix">
							<?php
								if (!empty($blog['BlogTag'])) :
									foreach($blog['BlogTag'] As $blog_tag) :
							?>
							<li class="grid_left"><?php echo $this->Html->cText($blog_tag['name']);?></li>
							<?php
									endforeach;
								else:
							?>
							<li class="round-5"><p class="notice"><?php echo __l('No tags available');?></p></li>
							<?php
								endif;
							?>
						</ul>
					</div>
					</div>
					</div>

						<?php if(Configure::read('Project.is_project_update_comment_enabled')): ?>
						<div class="clearfix blogComments-section">
							<?php echo $this->element('blog_comments-index', array('blog_id' => $blog['Blog']['id'], 'config' => 'sec', 'key' => $blog['Blog']['id'])); ?>
						</div>
						<div class="clearfix">
							<?php
								if($this->Auth->user('id')):
									 echo $this->element('blog_comments-add', array('blog_id' => $blog['Blog']['id'], 'config' => 'sec', 'key' => $blog['Blog']['id']));
								 else:?>
									   <p class="notice"><?php echo sprintf(__l('Please %s to post comment'), $this->Html->link(__l('login'), array('controller' => 'users', 'action' => 'login', '?' => 'f=project/' . $blog['Project']['slug']), array('title' => 'login'))) ;?></p>
							<?php endif; ?>
						</div>
					<?php endif; ?>
				</li>
				<?php endforeach; ?>
			<?php else: ?>
				<li>
					<p class="notice"><?php echo __l('No updates available'); ?></p>
				</li>
			<?php endif; ?>
			</ol>

			
		<?php if (!empty($blogs)) { ?>
			<div class="js-pagination">
				<?php echo $this->element('paging_links'); ?>
			</div>
		<?php } ?>
		</div>
			</div>
							</div>
						</div>
						<div class="l-curve-bot">
							<div class="r-curve-bot">
								<div class="bot-bg"></div>
							</div>
						</div>
	</div>
</div>